package com.baoli.blzj.utils;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.widget.Toast;


import com.baoli.blzj.Constants;

import static android.content.Context.MODE_PRIVATE;
import static com.baoli.blzj.Constants.SPN_USER_PHONE;

/**
 * 注销工具类 by John on 16/11/5.
 */

public class CancelPublicUtil implements Constants {

    public SharedPreferences spn;
    public SharedPreferences.Editor editor;

    public void deleteData(Context context,String msg) {
        spn = context.getSharedPreferences(SPN_BLZJ, MODE_PRIVATE);
        editor = spn.edit();
        Toast.makeText(context,msg,Toast.LENGTH_LONG).show();
        deleteLocalData(context);
    }

    public static CancelPublicUtil getInstance() {
        CancelPublicUtil ca = new CancelPublicUtil();
        return ca;
    }

    public void deleteLocalData(Context context) {
        editor.putString(SPN_USER_PHONE, "");
        editor.putString(SPN_CLOSE, "");
        editor.putString(SPN_SQID, "");
        editor.putString(SPN_SQNAME, "");
        editor.putString(SPN_SQIMG, "");
        editor.putBoolean(SPN_IS_SELECT_SHEQU, false);
        editor.putString(SPN_USER_PHONE, "");
        editor.putString(SPN_UID, "");
        editor.putString(SPN_USER_HEAD, "");
        editor.putString(SPN_NICK_NAME, "");
        editor.putString(SPN_USER_NOTE, "");
        editor.putString(SPN_AUTH_NAME, "");
        editor.putString(SPN_AUTH_PHONE, "");
        editor.putString(SPN_AUTH_BUILDING, "");
        editor.putString(SPN_AUTH_UNIT, "");
        editor.putString(SPN_AUTH_ROOM, "");
        editor.putBoolean(SPN_IS_LOGIN, false);
        editor.putBoolean(SPN_USER_CHECKIN, false);
        editor.putBoolean(SPN_AUTH, false);
        editor.putString(SPN_POINTS_TOTLA, "");
        editor.putString(SPN_EXPRESS, "");
        editor.putString(SPN_INFO, "");
        editor.putString(SPN_BBS, "");
        editor.putBoolean(SPN_IS_BANKCHECK, false);
        editor.putBoolean(SPN_IS_BANKPWD, false);
        editor.putString(SPN_BALANCE, "");
        editor.putString(SPN_USER_PASSWD, "");
        editor.commit();
       /* TsqApplication.getInstance().closeActivity();
        DatabaseHandler.getIntance().clearTable();
        MainActivity.mainActivity.finish();
        context.startActivity(new Intent(context, PersonalClearLoginActivity.class));*/
    }
}
